//
//  NewLottery.m
//  WangLottery
//
//  Created by leven hu on 12-4-22.
//  Copyright 2012年 __MyCompanyName__. All rights reserved.
//

#import "NewLottery.h"

@implementation NewLottery

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
        self.hidesBottomBarWhenPushed=YES;
        
    }
    return self;
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.title=@"最新开奖";
   
    // Do any additional setup after loading the view from its nib.
   /* UIBarButtonItem *helpBtn =[[UIBarButtonItem alloc] initWithTitle:@"历史开奖" style:UIBarButtonItemStylePlain target:self action:@selector(historyList)];   
    self.navigationItem.rightBarButtonItem = helpBtn; 
    [helpBtn release];*/

   // [self changeBackNavItem];
    
    //数据初始化
    lotteryCount=[[NSArray alloc]initWithObjects:@"一等奖",@"二等奖",@"三等奖",@"四等奖",@"五等奖",@"六等奖", nil];
    
    //界面初始化
    [self initViewControl];

}

- (void)dealloc{

    [lotteryCount release];
    [lotteryTable release];
    
    [super dealloc];
}

- (void)initViewControl{

    lotteryTable.rowHeight=25;
    [lotteryTable setSeparatorColor:[UIColor clearColor]];
    lotteryTable.userInteractionEnabled=NO;
}

- (void)viewDidAppear:(BOOL)animated{

    UIButton *history=[UIButton buttonWithType:UIButtonTypeRoundedRect];
    history.bounds=CGRectMake(0, 0, 60, 30);
    [history setTitle:@"历史开奖" forState:UIControlStateNormal];
    [history addTarget:self action:@selector(historyList) forControlEvents:UIControlEventTouchUpInside];
    
    UIBarButtonItem *btn = [[UIBarButtonItem alloc] initWithCustomView:history];
    self.navigationItem.rightBarButtonItem = btn;
    [btn release];
    

}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}



- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{

    return 6;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

    static NSString *string=@"Mr.hu";
    UITableViewCell *cell=[[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:string]autorelease];
    
    UILabel *lable1=[[UILabel alloc] init];
    lable1.frame=CGRectMake(5, 0, 60, 40);
    lable1.backgroundColor=[UIColor clearColor];
    lable1.text=[lotteryCount objectAtIndex:indexPath.row];
    lable1.textAlignment=UITextAlignmentCenter;
    lable1.textColor=[UIColor redColor];
    [cell addSubview:lable1];
    [lable1 release];
    
    UILabel *lable2=[[UILabel alloc] init];
    lable2.frame=CGRectMake(120, 0, 60, 40);
    lable2.backgroundColor=[UIColor clearColor];
    lable2.text=@"0";
    lable2.textAlignment=UITextAlignmentCenter;
    lable2.textColor=[UIColor redColor];
    [cell addSubview:lable2];
    [lable2 release];
    
    UILabel *lable3=[[UILabel alloc] init];
    lable3.frame=CGRectMake(220, 0, 60, 40);
    lable3.backgroundColor=[UIColor clearColor];
    lable3.text=@"0";
    lable3.textAlignment=UITextAlignmentCenter;
    lable3.textColor=[UIColor redColor];
    [cell addSubview:lable3];
    [lable3 release];
    
    
    
    return cell;

}

#pragma userAction

- (void)historyList{
    
    HistoryLotteryList *viewController = [[HistoryLotteryList alloc] initWithNibName:@"HistoryLotteryList" bundle:nil];
    viewController.hidesBottomBarWhenPushed=YES;
    viewController.title=@"历史开奖";
    [self.navigationController pushViewController:viewController animated:YES];
    
}



@end
